Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Add DDS support for {text,icon}-size #8593

Merged
merged 10 commits into from
Apr 6, 2017
Merged

Conversation

anandthakker
Copy link
Contributor

@anandthakker anandthakker commented Mar 31, 2017

  • Work through render test errors and segfaults ( 😱 )
  • Review SymbolSizeData / SymbolSizeAttributes design ( @jfirebaugh could I get your take on this? Main place to look/start is probably top of symbol_program.cpp, SymbolLayout::addSymbol, and maybe makeValues())
  • Refactor SymbolProgram, currently just copy-pasted from Program to make for easier initial hacking.
  • Correct naive linear interpolation to make use of exponential base.
  • Smaller TODOs
  • Request full review

@anandthakker anandthakker added Core The cross-platform C++ core, aka mbgl ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Mar 31, 2017
@anandthakker anandthakker force-pushed the dds-text-size branch 2 times, most recently from a85307b to 545ca67 Compare March 31, 2017 15:03
@jfirebaugh jfirebaugh self-requested a review March 31, 2017 20:16
: sizePropertyValue(size),
layoutZoom(tileZoom + 1),
defaultSize(defaultSize_) {
size.match(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some pathways don't initialize layoutSize. Should it have a default value or be typed as optional<float>?

struct SymbolSizeAttributes : gl::Attributes<attributes::a_size> {
using SourceFunctionVertex = gl::detail::Vertex<gl::Attribute<uint16_t, 1>>;
struct monostate {};
using VertexVector = variant<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having parallel VertexVector and VertexBuffer variants, and three different match statements (in attributeBindings, SymbolSizeData, and upload), what about following a model like PaintPropertyBinder, where an initial match statement then transfers control to a polymorphic object, whose derived types each hold both VertexVector and VertexBuffer of the appropriate matching types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah! I started out thinking that duplicating a PaintPropertyBinder hierarchy like that would be overkill, but actually it could be pretty minimal/scoped and, like you say, cleaner than having all these different matches. 🙇

anandthakker added a commit that referenced this pull request Apr 3, 2017
This fixes a bug where, for a zoom value greater than that of the highest zoom
stop, composite function interpolation would return nan. (Blocking a render
test over in #8593)

* Add failing tests for composite function edge case

The failing cases here are:
 - Should interpolate before the first stop
 - Should interpolate past the last stop

* Fix edge case in composite function interpolation

* Hold functions constant outside stop-defined domain
@anandthakker
Copy link
Contributor Author

@jfirebaugh refactored to a paintpropertybinders-like polymorphic approach f219d8c, as you suggested. It's a few more LOC, but it does feel like a cleaner design. The repetition of the PaintPropertyBinders hierarchy makes me itch to refactor the redundancy, but it would probably be premature abstraction to do it just yet; I think we should wait till we need a third copy.

@anandthakker
Copy link
Contributor Author

Refactor SymbolProgram, currently just copy-pasted from Program to make for easier initial hacking

I think the main issue here is to dedupe the identical constructors of SymbolProgram and Program (e.g.: https://github.com/mapbox/mapbox-gl-native/pull/8593/files#diff-5907166344b0d46b118326c98eb9915cR312). They're really just initializing a gl::Program, so I think that logic can be extracted into a static factor function or maybe even just a constructor for gl::Program.

@@ -37,6 +41,57 @@ class Program {
attributeLocations(Attributes::loadNamedLocations(binaryProgram)),
uniformsState(Uniforms::loadNamedLocations(binaryProgram)) {
}

template <class Shaders>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce binary size, pass vertexSource, fragmentSource, and name as parameters rather than templating on Shaders.

// Layout attributes

MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_extrude);
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_pos_offset);
MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, a_texture_pos);

template <std::size_t N>
template <std::size_t N, typename T>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flip the order of T and N, so that it matches gl::Attribute.

@boundsj boundsj added this to the ios-v3.6.0 milestone Apr 5, 2017
@anandthakker anandthakker force-pushed the dds-text-size branch 2 times, most recently from 66b27fb to 8af6500 Compare April 5, 2017 21:11
@anandthakker
Copy link
Contributor Author

@jfirebaugh updated to address your comments and also rebased + cleaned up the history a bit. Should be ready for a full review now.

@anandthakker anandthakker force-pushed the dds-text-size branch 2 times, most recently from bb0463d to 24f10e8 Compare April 6, 2017 11:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants